<template>
  <div>
    <!-- 商品详情 -->
    <Header></Header>
    <van-sticky>
      <van-nav-bar
        title="商品列表"
        left-text="返回"
        left-arrow
        @click-left="onClickLeft"
        right-text="返回顶部"
        @click-right="onClickright"
      />
    </van-sticky>
    <div class="main">
      <div class="main-hd">
        <p>{{ desclist.title }}</p>
      </div>
      <p v-html="desclist.content"></p>
    </div>
  </div>
</template>

<script>
import { getdesc } from "../api/goods";
import Header from "../components/header.vue";

export default {
  data() {
    return {
      desclist: [],
    };
  },
  components: {
    Header,
  },
  async created() {
    const { data: res } = await getdesc(this.$route.params.id);
    console.log(res);
    this.desclist = res.message[0];
  },
  methods: {
    onClickLeft() {
      this.$router.go(-1);
    },
    onClickright() {
      window.scrollTo({
        top: 0,
        behavior: "smooth",
      });
    },
  },
};
</script>

<style lang="less" scoped>
.main {
  padding: 10px 10px;

  .main-hd {
    color: #0088d1;
    font-size: 20px;
    font-weight: 700;
    padding-bottom: 10px;
    border-bottom: 1px solid #ccc;
    .main-item {
      display: flex;
      align-items: center;
      font-size: 12px;
      color: #999;
      padding-top: 5px;
      span {
        margin-right: 5px;
      }
    }
  }

  .main-img {
    .van-image {
      padding: 10px;
    }
    p {
      color: #666;
      margin-bottom: 40px;
    }
  }
}
</style>
